package com.xrh.xdemo.api.request.queryRequest;

import java.util.Date;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class OperateTraceQueryRequest {

    /**主键id */
	@ApiModelProperty("主键id")
	private Long id;

	/**操作时间 */
	@ApiModelProperty("操作时间")
	private Date operateTimeStart;

	/**操作时间 */
	@ApiModelProperty("操作时间")
	private Date operateTimeEnd;

	/**操作人用户id */
	@ApiModelProperty("操作人用户id")
	private Long operateUserId;

	/**操作人用户账号 */
	@ApiModelProperty("操作人用户账号")
	private String operateUserAccount;

	/**操作人用户工号 */
	@ApiModelProperty("操作人用户工号")
	private String operateUserJobNo;

	/**操作类型 */
	@ApiModelProperty("操作类型")
	private String operateType;

	/**业务类型 */
	@ApiModelProperty("业务类型")
	private String businessType;

	/**业务编号 */
	@ApiModelProperty("业务编号")
	private String businessNo;

    @ApiModelProperty(value = "当前页码" )
    private Integer pageNum = 1;

    @ApiModelProperty(value = "每页数量" )
    private Integer pageSize = 10;

	 //获取查询条件,注释部分要自己填写
	public <T> QueryWrapper<T> createQuery() {
			
		QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
		
		if(id != null)
			queryWrapper.eq("id", id);

		if(operateTimeStart != null)
			queryWrapper.ge("operate_time", operateTimeStart);

		if(operateTimeEnd != null)
			queryWrapper.le("operate_time", operateTimeEnd);

		if(operateUserId != null)
			queryWrapper.eq("operate_user_id", operateUserId);

		if(StrUtil.isNotBlank(operateUserAccount))
			queryWrapper.eq("operate_user_account", operateUserAccount);

		if(StrUtil.isNotBlank(operateUserJobNo))
			queryWrapper.eq("operate_user_job_no", operateUserJobNo);

		if(StrUtil.isNotBlank(operateType))
			queryWrapper.eq("operate_type", operateType);

		if(StrUtil.isNotBlank(businessType))
			queryWrapper.eq("business_type", businessType);

		if(StrUtil.isNotBlank(businessNo))
			queryWrapper.eq("business_no", businessNo);

		return queryWrapper;
	}
		
	//获取分页
   public <T> Page<T> createPage(){
	   return new Page<>(pageNum , pageSize);
   }
	   
}
